<template>
  <DataList :cate="cate" :cols="cols" skipExcelNumber="2" :excelHeader="excelHeader" :groupCheck = "groupCheck" :name="name"/>
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addJfsrmx1,deleteJfsrmx1,updateJfsrmx1,getJfsrmx1,bulkAddJfsrmx1 } from "@/api/学费收入.js";
import { debuglog } from 'util';
import linq from "linq"
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A5-1-1学费收入",
      name: '5.1.1 学费收入',
      excelHeader:{B3:"学生类别",C3:"标准（元/生）",D3:"金额（万元）"},
      cols: [
        { label: "学生类别", prop: "XFSRXSLB" },
        { label: "标准(元/生)", prop: "XFSRBZ" },
        { label: "金额(万元)", prop: "XFSRJE" }
      ],
       groupCheck:[{data:["XFSRXSLB","XFSRBZ","XFSRJE"],desc:'请完善输入'}]
    };
  },
  methods: {



    
    getSummaries(list){
      //
        const sums = [];
          this.cols.forEach((column, index) => {
            sums[index]="";
          });
          sums[0]="合计";
          sums[6]= "类别数:"+linq.from(list).distinct("$.XFSRXSLB").count()
          sums[8]= "合计:"+linq.from(list).sum("$.XFSRJE")
          sums[9]= "通过:"+linq.from(list).where("$.审核状态=='通过'").count();
          sums[9] += ",不通过:"+linq.from(list).where("$.审核状态=='不通过'").count();
          sums[9] += ",待审核:"+linq.from(list).where("$.审核状态=='待审核'").count();
        return sums;
    },
     check(array,list) {
     return new Promise(async (resolve,reject)=>{
         try{
          var user = getUser();
         
            resolve();
          }catch(e){
            reject(e);
          }
     }) 
    },
    async fetchData() {
      var user = getUser();
      var datas = await getJfsrmx1(user.XXID,user.CJPC);
      return datas;
    },
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addJfsrmx1(temp);
          resolve(model);
      })
      
    },
    async  bulkAdd(array){
       await  bulkAddJfsrmx1({Jfsrmx1:array});
       console.log(array)
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateJfsrmx1(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteJfsrmx1(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>